<?php
$this->Html->scriptBlock($script, array('inline' => false));
$this->Html->scriptBlock($scriptSearchBox, array('inline' => false));
?>
<div class="title-body-content"><?php echo $title_for_layout; ?></div>
<div class="searchbox" style="margin-top: 15px;">
    Bank &nbsp;<select id="match_bank_id" name="match_bank" style="padding:2px 0; width: 100px;">
        <option value="all">All</option>
        <?php echo $banks; ?>
    </select>
    &nbsp;&nbsp;From &nbsp;<input type="text" id="match_from_id" readonly="readonly" value="<?php echo date('m/d/Y', strtotime(date('Y-m-d H:i:s'))-30*24*60*60);?>" class="sel-date" name="match_from" />
    &nbsp;&nbsp;To &nbsp;<input type="text" id="match_to_id" readonly="readonly" value="<?php echo date('m/d/Y');?>" class="sel-date" name="match_to" />
    <input type="button" id="search_button" value="Match" class="searchbutton" />
</div>
<div class="wrapper-table clearfix">
    <table class="tbl-broking" border="1">
        <tr class="title-tbl" >
            <td class="td-bank-name"><?php echo $this->Paginator->sort('name', 'Bank Name'); ?></td>
            <td class="td-bank-address"><?php echo __('Bank Address'); ?></td>
            <td class="td-swift"><?php echo $this->Paginator->sort('swift_code', 'SWIFT'); ?></td>
            <td class="td-bank-acc"><?php echo $this->Paginator->sort('date'); ?></td>
            <td class="td-bank-acc"><?php echo $this->Paginator->sort('reference_of_transaction', 'Reference of Transaction'); ?></td>
            <td class="td-bank-acc"><?php echo $this->Paginator->sort('amount'); ?></td>
            <td class="td-menu"><?php echo __('Actions'); ?></td>
        </tr>
        <?php
        foreach ($reconciliations AS $reconciliation) {
            $actions = '<li>' . $this->Html->link(__('Edit'), array(
                        'controller' => 'reconciliations',
                        'action' => 'edit',
                        $reconciliation['Reconciliation']['id'],
                    )) . '</li>';
            $actions .= ' ' . $this->Layout->adminRowActions($reconciliation['Reconciliation']['id']);
            $actions .= ' <li><div class="space3">|</div>' . $this->Html->link(__('Delete'), array(
                        'controller' => 'reconciliations',
                        'action' => 'delete',
                        $reconciliation['Reconciliation']['id'],
                        'token' => $this->params['_Token']['key'],
                            ), null, __('Are you sure you want to delete this Bank Reconciliate?')) . '</li>';

            echo '
                    <tr class="line-content-tbl" >
                        <td class="td-bank-name" style="text-align:left; padding-left:4px;">' . $reconciliation['Reconciliation']['name_of_bank'] . '</td>
                        <td class="td-bank-address" style="text-align:left; padding-left:4px;">' . $reconciliation['Reconciliation']['address_of_bank'] . '</td>
                        <td class="td-swift">' . $reconciliation['Reconciliation']['swift_code'] . '</td>
                        <td class="td-bank-acc">' . date('m/d/Y', strtotime($reconciliation['Reconciliation']['date'])) . '</td>
                        <td class="td-bank-acc">' . $reconciliation['Reconciliation']['reference_of_transaction'] . '</td>
                        <td class="td-bank-acc" style="text-align:right; padding-right:4px;">' . $reconciliation['Reconciliation']['currency'] . ' ' . number_format($reconciliation['Reconciliation']['amount'], 2) . '</td>
                        <td class="td-action">
                            <ul>
                                ' . $actions . '
                            </ul>
                        </td>
                    </tr>';
        }
        ?>
    </table>
    <div class="wrapper-table clearfix" style="font-style: italic;">
        There are all transactions from your bank. Click new to input data which your bank supplied you.
    </div>
    <div class="wrapper-paging">
        <ul class="ul-paging">
            <?php echo $this->Paginator->numbers(array('tag' => 'li', 'separator' => '')); ?>
        </ul>
        <?php #echo $this->Paginator->counter(array('format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%'))); ?>
    </div>
    <div class="wrapper-button-form">
        <div class="button-form">
            <div class="button-aihre button-blue"><?php echo $this->Html->link(__('NEW'), array('action' => 'add')); ?></div>
        </div>
    </div>
</div>
<?php
$datePicker = "
    $(function() {
        $('#match_from_id').datepicker({ changeYear: true, dateFormat: 'm/d/yy'});
        $('#match_to_id').datepicker({ changeYear: true, dateFormat: 'm/d/yy'});
        return false;
    });";
$this->Html->scriptBlock($datePicker, array('inline' => false));
?>